package com.bupt.liutong.admin.sch.form;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;

import com.bupt.liutong.admin.core.base.BaseForm;
import com.bupt.liutong.admin.core.base.Photo;
import com.bupt.liutong.admin.core.base.PhotosForm;
import com.bupt.liutong.admin.sch.dto.TeacherPhoto;

public class TeacherForm extends BaseForm implements PhotosForm {

	private static final long serialVersionUID = 3104497496784905968L;
	private Integer id;
	private String name;
	private String enName;
	private String des;
	private String position;
	private String mainPic;
	private FormFile mainPicFile;
	
	private String[] photoDeses = new String[20];
	private Integer[] photoIds = new Integer[20];
	private Integer[] photoSeqs = new Integer[20];
	
	private String[] newPhotoDeses = new String[5];
	private FormFile[] newPhotoFiles = new FormFile[5];

	public String getEnName() {
		return enName;
	}

	public void setEnName(String enName) {
		this.enName = enName;
	}

	public String[] getNewPhotoDeses() {
		return newPhotoDeses;
	}

	public void setNewPhotoDeses(String[] newPhotoDeses) {
		this.newPhotoDeses = newPhotoDeses;
	}

	public FormFile[] getNewPhotoFiles() {
		return newPhotoFiles;
	}

	public void setNewPhotoFiles(FormFile[] newPhotoFiles) {
		this.newPhotoFiles = newPhotoFiles;
	}

	public String getPosition() {
		return position;
	}

	public void setPosition(String position) {
		this.position = position;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDes() {
		return des;
	}

	public void setDes(String des) {
		this.des = des;
	}

	public String[] getPhotoDeses() {
		return photoDeses;
	}

	public void setPhotoDeses(String[] photoDeses) {
		this.photoDeses = photoDeses;
	}

	public Integer[] getPhotoIds() {
		return photoIds;
	}

	public void setPhotoIds(Integer[] photoIds) {
		this.photoIds = photoIds;
	}

	/**
	 * Method validate
	 * 
	 * @param mapping
	 * @param request
	 * @return ActionErrors
	 */
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		// TODO Auto-generated method stub
		return null;
	}

	/**
	 * Method reset
	 * 
	 * @param mapping
	 * @param request
	 */
	public void reset(ActionMapping mapping, HttpServletRequest request) {
		// TODO Auto-generated method stub
	}

	
	public Photo getNewPhoto(int i) {
		TeacherPhoto photo = new TeacherPhoto();
		photo.setTeacherId(this.id);
		photo.setDes(this.newPhotoDeses[i]);
		photo.setFile(this.newPhotoFiles[i]);
		return photo;
	}

	
	public Photo getPhoto(int i) {
		TeacherPhoto photo = new TeacherPhoto(photoIds[i], photoDeses[i]);
		photo.setSeq(photoSeqs[i]);
		return photo;
	}

	
	public Integer[] getPhotoSeqs() {
		return photoSeqs;
	}

	
	public void setPhotoSeqs(Integer[] photoSeqs) {
		this.photoSeqs = photoSeqs;
	}

	public String getMainPic() {
		return mainPic;
	}

	public void setMainPic(String mainPic) {
		this.mainPic = mainPic;
	}

	public FormFile getMainPicFile() {
		return mainPicFile;
	}

	public void setMainPicFile(FormFile mainPicFile) {
		this.mainPicFile = mainPicFile;
		if (mainPicFile != null)
			this.mainPic = mainPicFile.getFileName();
	}
}
